package com.ttn.entities;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Future;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotEmpty;


@Entity
@Table(name="connection")
public class Connection implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2521282257295753120L;
	
	@Id
	@Column(name="id")
	@GeneratedValue(strategy=IDENTITY)
	private int id;
	
	@Column(name="tripType")
	private String type;
	
	@ManyToOne
	@JoinColumn(name="user_id")
	private User user;
	
	@Column(name="from_location")
	@NotEmpty
	private String from;
	
	@Column(name="to_location")
	@NotEmpty
	private String to;
	
	@Column(name="tripPrice")
	private Double price;
	
	@Column(name="tripDate")
	@Future
	private Date tripDate;
	
	@Column(name="comment")	
	private String comment;
	
	@Column(name="seats_available")
	@Min(value=1)
	private int seatsAvailable;
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getFrom() {
		return from;
	}
	public void setFrom(String from) {
		this.from = from;
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	public Date getTripDate() {
		return tripDate;
	}
	public void setTripDate(Date tripDate) {
		this.tripDate = tripDate;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getId() {
		return id;
	}
	public int getSeatsAvailable() {
		return seatsAvailable;
	}
	public void setSeatsAvailable(int seatsAvailable) {
		this.seatsAvailable = seatsAvailable;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	
}
